*******************************************************
** 					REPLICATION MATERIAL 
** 
** "Do Authoritarian Elections Help the Poor? Evidence from Russian Cities"
**
**					   	   by 				 			 	  
**			Quintin H. Beazer & Ora John Reuter
**
**						     in							 	  
** 				The Journal of Politics		 	  
**													 	  
*******************************************************

* File created and checked May 2020 using Stata 14. To ask questions 
* or report a suspected error, please contact the authors. We are happy 
* to correspond with others about the project. Send emails to: 
* Quintin Beazer (qbeazer@fsu.edu) or John Reuter (reutero@uwm.edu) 

* This .do file contains code for subsetting the RLMS panel into the 2009
* responses associated with questions about public service delivery.  These 
* data are used to make Figure 1 in the main text.  
*  
* The dataset created by this file is required to run the code for 
* the associated plot in the accompanying .R script.


** set working directory
cd "XXXXX"  

** load data
use "HH_1994_2015_v1.dta" , clear

** keep only 2009 observations (only year with public services question)
keep if year == 2009 

** identify cities from main "cities" dataset 
gen city=""
replace city="Batajsk" if psu== 21 
replace city="Bijsk" if psu== 33 
replace city="Cheljabinsk" if psu== 25 
replace city="Glazov" if psu== 27 
replace city="Kazan'" if psu== 16 
replace city="Krasnodar" if psu== 22 
replace city="Krasnojarsk" if psu== 35 
replace city="Kurgan" if psu== 26 
replace city="Lipeck" if psu== 14 
replace city="Miass" if psu== 30 
replace city="Nizhnij Novgorod" if psu== 11 
replace city="Orsk" if psu== 28 
replace city="Saratov" if psu== 17 
replace city="Smolensk" if psu== 7 
replace city="Solikamsk" if psu== 29 
replace city="Syktyvkar" if psu== 4 
replace city="Tambov" if psu== 38 
replace city="Tomsk" if psu== 31 
replace city="Tula" if psu== 9 
replace city="Vladivostok" if psu== 36 
replace city="Berdsk" if psu== 32  & year>=2003

** keep only respondents from cities (not outlying rural areas)
tab city urban
keep if urban == 1 | urban == 2

** identify appointed vs elected status for each city (in 2009)
gen appointed = .
replace appointed=	0	 if psu== 21 
replace appointed=	0	 if psu== 33 
replace appointed=	0	 if psu== 25 
replace appointed=	0	 if psu== 27 
replace appointed=	1	 if psu== 16 
replace appointed=	0	 if psu== 22 
replace appointed=	0	 if psu== 35 
replace appointed=	1	 if psu== 26 
replace appointed=	0	 if psu== 14 
replace appointed=	0	 if psu== 11 
replace appointed=	0	 if psu== 28 
replace appointed=	1	 if psu== 17 
replace appointed=	1	 if psu== 7 
replace appointed=	0	 if psu== 29 
replace appointed=	1	 if psu== 4 
replace appointed=	0	 if psu== 31 
replace appointed=	1	 if psu== 9 
replace appointed=	0	 if psu== 36 
replace appointed=	0	 if psu== 32  & year>=2003

** remove observations without values for "appointed"
drop if appointed == .


*** questions about satisifaction with housing and neighborhoods (only 2009)
******************************************************************************

* unsatisfied with water supply? 1=yes
tab c711_01
gen satwater = 0 if year==2009
replace satwater=1 if c711_01==1

* unsatisfied with gas supply? 1=yes 
tab c711_02
gen satgas = 0 if year==2009
replace satgas=1 if c711_02==2

* unsatisfied with waste disposal? 1=yes 
tab c711_04
sum c711_04
gen satwaste = 0 if year==2009
replace satwaste=1 if c711_04==4

* unsatisfied with building maintenance? 1=yes 
tab c711_09
sum c711_09
gen satbldg = 0 if year==2009
replace satbldg=1 if c711_09==9

* unsatisfied with lack of security? 1=yes (n=134)
tab c711_11
sum c711_11
gen satsec = 0 if year==2009
replace satsec=1 if c711_11==11

* concerns about dirty streets? 1=yes (n=1394)
tab c712_1
sum c712_1
gen satstreets = 0 if year==2009
replace satstreets=1 if c712_1==1

* concerns about absence of green spaces? 1=yes 
tab c712_2
sum c712_2
gen satparks = 0 if year==2009
replace satparks=1 if c712_2==2

* concerns about bugs, flies, etc? 1=yes 
tab c712_3
sum c712_3
gen satbugs2 = 0 if year==2009
replace satbugs2=1 if c712_3==3

* concerns about air pollution? 1=yes 
tab c712_4
sum c712_4
gen satair = 0 if year==2009
replace satair=1 if c712_4==4

* concerns about water pollution? 1=yes 
tab c712_5
sum c712_5
gen satwater2 = 0 if year==2009
replace satwater2=1 if c712_5==5

** making dataset for export to plot in R
keep satbldg satwater satgas satwaste satsec ///
satstreets satparks satbugs2 satair satwater2 ///
appointed city

* save to working directory
saveold "RLMS2009publicgoods.dta", ver(12) replace


** For reference: T-tests to be plotted in R
* DOM
ttest satbldg, by(appointed)
ttest satwater, by(appointed)
ttest satgas, by(appointed)
ttest satwaste, by(appointed)
ttest satsec, by(appointed)

* RAION
ttest satstreets, by(appointed)
ttest satparks, by(appointed)
ttest satbugs2, by(appointed)
ttest satair, by(appointed)
ttest satwater2, by(appointed)




